

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <link href="favicon.ico" rel="shortcut icon" />
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"  crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"  crossorigin="anonymous"></script>

    <script src="js/jquery.js"></script>
    <link rel="stylesheet" href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" />
    <script type="text/javascript" src="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>
    <style>
        body {
            background-image: url("img/a2.jpeg");

        }
    </style>
</head>
<body  class=".img-fluid">

<div class="modal-dialog" style="margin-top: 10%;">
    <div class="modal-content">
        <div class="modal-header">

            <h4 class="modal-title text-center" id="myModalLabel">登录</h4>
        </div>
        <div class="modal-body" id = "model-body">
            <div class="form-group">
                <div>用户名:</div>
                <input type="text" id="user" name="user" class="form-control"placeholder="用户名" autocomplete="off">
            </div>
            <div class="form-group">
                <div>密  码:</div>
                <input type="password" id="pwd" name="pwd" class="form-control" placeholder="密码" autocomplete="off">
            </div>
        </div>
        <div class="modal-footer">
            <div class="form-group col-12" >
                <button id="lo" type="button" class="btn btn-primary form-control">登录</button>
            </div>
            <div class="form-group col-12">
               <a href="/register"><button type="button" class="btn btn-default form-control">注册</button></a>
            </div>
        </div>
    </div><!-- /.modal-content -->
</div><!-- /.modal -->
<script>
     $(function () {
         /*登录验证账号密码是否正确*/
          $("#lo").click(function () {
                var u =$("#user").val();
              var p =$("#pwd").val();
              $.get("doLogin",{"user":u,"pwd":p},function (data) {
                       var l=eval(data);
                       if(l>0){
                           swal({
                               title:"非常好",
                               text:"登录成功",
                               type:"success",
                               icon:"success",
                               button:"确定"
                           },function () {
                               window.location="/index";
                           })


                       }else{
                           swal({
                               title: "注意",
                               text: "用户名或密码不正确",
                               type: "warning",
                               icon:"warning",
                               button: "确定",
                           },function () {
                               window.location="/login";
                           })


                       }
              })
          })
     })
</script>
</body>
</html>